<script>
	var doupdate='__URL__/doupdate';
	var obj=new Object();
	var addormdf="{$id}";
	obj["{$lowmdmk}"+"id"]="{$id}";
</script>
<!--table部分-->
<div class='col-md-12' style='padding-top: 20px'>
	<!--开始-->
	<table class='table table-hover table-striped table-bordered'>
		<tbody>
			<?php foreach($para as $k=>$v){
					if(!in_array($k, $no_update)){
			 ?>

			<?php if($k=='atcmdftm'){ ?>
			<?php $tm=$moforjs[$k];$tm=strtotime($tm)+1;$tm=date('Y-m-d H:i:s',$tm); ?>
			<script language="javascript" type="text/javascript" src="__PUBLIC__/etc/DatePicker/My97DatePickerHHmmss/WdatePicker.js"></script>
			<tr><td>{$v}</td><td><input id='atcmdftm' onclick="WdatePicker()" value="{$tm}" readonly >清除时间就会默认当前时间</td></tr>
			<script>$('#atcmdftm').val("{$tm}");</script>
			<?php continue;} ?>

			<?php if($k!='atcctt'&&$k!='atccv'&&$k!='atcsmr'){ ?>
			<tr><td>{$v}</td><td>
			<?php if(strstr($k, '_')){ ?>
			<select id='{$k}'>
				<option value='0'>无</option>
				<?php //处理萃取下主题
                  $tmp=explode('_', $k);$tmp=explode('id',$tmp[2]);$tmp=$tmp[0];
                ?>
				<volist name='$k' id='v'><option value="<?php echo $v[$tmp.'id'] ?>"><?php echo $v[$tmp.'nm'] ?></option></volist>
			</select>
			<?php }else if(isset($transmean[$k])){ ?>
			<select id='{$k}'>
				<?php foreach($transmean[$k] as $v=>$dsc){ ?>
				<option value="{$v}">{$dsc}</option>
				<?php } ?>
			</select>
			<?php }else{ ?>
			<input id='{$k}'>
			<?php } ?>
			<script>var k="{$k}";var v="{$moforjs[$k]}";if(k.indexOf('_')!=-1&&v==''){$('#'+k).val('0');}else{$('#'+k).val(v);}</script>
			</td></tr>
			<?php } ?>
			<?php }
			} ?>
		</tbody>
	</table>
	<?php if($mo['atcath']==''){ ?><script>$('#atcath').val("{$usross['usrnn']}");</script><?php } ?>
	<!-- pt start -->
	封面：<br>
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/etc/huploadify/html5uploader.css"/>
	<script type="text/javascript" src="__PUBLIC__/etc/huploadify/jquery.html5uploader.js"></script>
	<script>var dogivetail='__APP__/Hupldf/dogivetail'</script>
		<script type="text/javascript">
	$(function(){
		$('#upload').html5uploader({
			fileTypeExts:'image/jpeg,image/png',
			auto:true,
			multi:false,
			removeTimeout:0,
			url:'__APP__/Hupldf/upload/folder/atccv',//
			onUploadStart:function(){
				//alert('开始上传');
				var timestamp = (new Date()).valueOf();
			},
			onInit:function(){
				//alert('初始化');
			},
			onUploadComplete:function(file){
				//alert('上传完成');
				$.post(
					'__APP__/Hupldf/showphoto',
					{},
					function(data){
						$('#imgg').attr('src',data.myfl);
						$('input[name=pt]').val(data.myfl);
					},
					'json'
				);
			}
		});
	});
	</script>
	<div><img <?php if($mo['atccv']){ ?>src="{$mo['atccv']}" <?php }else{ ?>src='/{$project}/Public/img/atccv/default.jpg'<?php } ?> class='thumbnail' style='max-width: 100%' id='imgg' /><input type='hidden' id='atccv' name='pt' value="{$mo['atccv']}"/></div>
	<div id="upload"></div>
    <!-- pt over -->

    <!--摘要-->
    摘要<br>
    <div><textarea id='atcsmr' style="width: 100%" placeholder='摘要允许为空'>{$mo['atcsmr']}</textarea></div>

	<script type="text/javascript">var project="{$project}";</script>
	<link rel="stylesheet" href="__PUBLIC__/etc/ueditor/themes/default/ueditor.css"/>
	<script type="text/javascript" src="__PUBLIC__/etc/ueditor/editor_config.js"></script>
	<script type="text/javascript" src="__PUBLIC__/etc/ueditor/editor_all.js"></script>
	<div>
	<p>文章内容</p>
	  <div id="myEditor">
		<script type="text/javascript">
			var editor = new baidu.editor.ui.Editor({
			    initialContent: '{$mo.atcctt}'
			});
			editor.render("myEditor");
		</script>
		</div>
	</div>
	<textarea id='atcctt' style='display:none'></textarea>
	<a class='btn btn-primary' id='update'><?php if($id==0){ ?>添加<?php }else{ ?>修改<?php } ?></a>
</div>

<script>
//自身参数，初始数据
var para=new Object();
var selfpara=new Array();
var origindata=new Object();

<?php 
foreach($para as $k=>$v){ 
	if(!in_array($k, $notself)){
?>
para["{$k}"]="{$v}";
selfpara.push("{$k}");
origindata["{$k}"]="{$moforjs[$k]}";
<?php 
	}
} 
?>

//的属性里面不用管的，也不用显示的
var no_update=new Array();
<?php 
foreach($no_update as $nuv){ 
?>
no_update.push("{$nuv}");
<?php 
} 
?>
//zabojin的属性里面在显示中，允许空的
var allowempty=new Array();
<?php 
foreach($allowempty as $aev){ 
?>
allowempty.push("{$aev}");
<?php 
} 
?>
//transmean
var transmeank=new Array();
<?php 
foreach($transmean as $tmvk=>$tmvv){ 
?>
transmeank.push("{$tmvk}");
<?php 
} 
?>

//#########
$(function(){
	$('#update').click(function(){
		//dingzhis
		$('#atcctt').val(editor.getContent());
		//dingzhio
		//首先把相关的参数数据聚集起来，把自身更新需要的参数以及变动的数据进行传输
		//由于第一个往往是id所以，就不去考虑了
		//先判断是否为空
		for(var i=1;i<selfpara.length;i++){
			var key=selfpara[i];var tmp=$('#'+key);
			//如果是允许空的，就不用考虑他有没有空的事情了；反之不在这里头，就要考虑了
			if(no_update.indexOf(key)==-1&&allowempty.indexOf(key)==-1){var tagname=tmp.get(0).tagName;
				if(tagname=='INPUT'&&$.trim(tmp.val())==''){
					msg(para[key]+'不能为空');tmp.focus();return;
				}else if(transmeank.indexOf(key)==-1&&tagname=='SELECT'&&$.trim(tmp.val())=='0'){
					msg(para[key]+'未选择');tmp.focus();return;
				}
			}
			
		}
		//然后判断哪些是有变动的，变动的数值需要提交修改，没有变动的则直接不用接后台了
		//其中添加需要全盘给上，修改只用给变量就行
		if(addormdf!=0){
			var flag_change=0;
			for(var i=1;i<selfpara.length;i++){
				//排除掉不用管的
				var key=selfpara[i];var tmp=$('#'+key);var valuenow=$.trim(tmp.val());
				if(no_update.indexOf(key)==-1){
					if(valuenow!=origindata[key]){
						flag_change=1;
						obj[key]=valuenow;
					}
				}
			}
			if(flag_change==0){msg('没有任何信息改变');return;}
		}else{
			for(var i=1;i<selfpara.length;i++){
				var key=selfpara[i];var tmp=$('#'+key);var valuenow=$.trim(tmp.val());
				if(no_update.indexOf(key)==-1){
					obj[key]=valuenow;
				}
			}
		}
		$.post(
			doupdate,
			obj,
			function(data){
				
				var str='';
            	if(data['pattern']=='0'){str='添加';}else{str='修改';}
            	msg(str+'成功！点击返回',2);
            	
                console.log("success");
			
			
			},
			'json'
		);

		// $.ajax({
  //           'type': 'GET',
  //           'url':doupdate,
  //           'async':false,  
  //           'contentType': 'application/json',
  //           'data': obj,
  //           'dataType': 'json',
  //           'success': function(data) {
  //           	var str='';
  //           	if(data['pattern']=='0'){str='添加';}else{str='修改';}
  //           	alert(str+'成功！点击返回');
  //           	window.location.href=document.referrer;
  //               console.log("success");
  //           },
  //           'error':function() {
  //               console.log("error");
  //           }
  //       });
	})
})
</script>